home *** CD-ROM | disk | FTP | other *** search
- Path: news.cern.ch!danpop
- From: danpop@mail.cern.ch (Dan Pop)
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: Re: sizeof() question >>> :)
- Date: 18 Apr 96 10:25:23 GMT
- Organization: CERN European Lab for Particle Physics
- Message-ID: <danpop.829823123@news.cern.ch>
- References: <1996Apr12.061927@topaz> <31714828.1574068@news.linex.com> <4l0dcr$14t0@darwin.nbnet.nb.ca> <danpop.829678939@news.cern.ch> <4l4fik$1a8_005@donstarr.best.com>
- NNTP-Posting-Host: ues5.cern.ch
- Mime-Version: 1.0
- Content-Type: text/plain; charset=US-ASCII
- Content-Transfer-Encoding: 7bit
- X-Newsreader: NN version 6.5.0 #18 (NOV)
-
- In <4l4fik$1a8_005@donstarr.best.com> super@donstarr.org (Don Starr) writes:
-
- >In article <danpop.829678939@news.cern.ch>,
- > danpop@mail.cern.ch (Dan Pop) wrote:
- >*>
- >*> If you allocate the space for the array you can call one of the memory
- >*> routines which return the size of the allocation.
- >*> Dave Gaudet via Rick Bruce
- >*
- >*There is no such "routine" in the C language.
- >*
- >*Dan
- >
- >Technically, there is no such _any_ routine in the C language. The language
- >doesn't define any functions - "standard" libraries do.
-
- When you use the word "technically", check that your statement is
- technically correct, first. The standard (no need for quotes here)
- C library specification is a part of the C language definition.
- Check the ISO/IEC 9899:1990 standard for further enlightment.
-
- >As to the original question, if you know how your heap is structured (from
- >the source to your malloc(), new, or whatever), you can get the size of any
- >allocation from it.
-
- "Technically" bullshit, although it might work in practice, for a given
- platform and implementation version. The code could crash and burn even
- when upgrading to the next version.
-
- Any attempt to access memory outside of an allocated block results in
- undefined behaviour. Check the above mentioned standard if you don't
- know already what this means.
-
- Dan
- --
- Dan Pop
- CERN, CN Division
- Email: danpop@mail.cern.ch
- Mail: CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland
-